package com.epam.task.web.dao;

import com.epam.task.web.app.ConnectionToDB;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.*;

/**
 * Created with IntelliJ IDEA.
 * User: zhunusbekova.arailym
 * Date: 25.09.13
 * Time: 17:35
 * To change this template use File | Settings | File Templates.
 */

public class ExecuteUpdateToDB {
    public static final Logger LOGGER = LoggerFactory.getLogger(ConnectionToDB.class);
    public static void main(String[] args) {
        Connection con = null;
        Statement st = null;
        ResultSet rs = null;
        try {
            Class.forName("org.gjt.mm.mysql.Driver");
            con = DriverManager.getConnection("jdbc:mysql://127.0.0.1/test","root", "123456");
                    st = con.createStatement();
            int countRows = st.executeUpdate(
                    "INSERT INTO oc_product (name, id_group) VALUES (\"Баба-Яга\",123456)");
            LOGGER.info(String.valueOf(countRows));
        } catch (ClassNotFoundException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        } catch (SQLException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
    }
}

